package com.example.zx.theline.usercenter;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.zx.theline.R;


import base.BaseActivity;
import dialog.FirstInstallDialog;

public class    UserCenterActivity extends BaseActivity implements View.OnClickListener {

    //更新字典表，常见问题帮主，技术支持
    Button upuserinfo,help,support;
    FirstInstallDialog mFirstInstallDialog;
    TextView centerTextView;
    TextView leftTextView;
    TextView rightTextView;

    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_center);
        InitView();
        InitData();
        InitListen();
    }

    @Override
    protected void InitView() {
        upuserinfo = (Button) findViewById(R.id.upuserinfo);
        help = (Button) findViewById(R.id.help);
        support = (Button) findViewById(R.id.support);
        centerTextView= (TextView) findViewById(R.id.centerTextView);
        leftTextView= (TextView) findViewById(R.id.leftTextView);
        rightTextView= (TextView) findViewById(R.id.rightTextView);
    }

    @Override
    protected void InitData() {
        centerTextView.setText("用户中心");

    }

    @Override
    protected void InitListen() {


        //根据登录用户ID更新本地数据库，该ID部门下的所有人员信息
        upuserinfo.setOnClickListener(this);
        leftTextView.setOnClickListener(this);
        help.setOnClickListener(this);
        support.setOnClickListener(this);
        rightTextView.setVisibility(View.GONE);

    }

    @Override
    public void onClick(View v) {

        switch(v.getId()){
            case R.id.leftTextView:
                finish();
                break;
            case R.id.upuserinfo:
                mFirstInstallDialog=new  FirstInstallDialog(this);
                mFirstInstallDialog.show();
                break;
            case R.id.help:
                intent=new Intent(this,HelpActivity.class);
                startActivity(intent);
                break;
            case R.id.support:
                intent=new Intent(this,SupportActivity.class);
                startActivity(intent);
                break;
        }
    }

//    //根据登录用户ID更新本地数据库，该ID部门下的所有人员信息
//    private void DownLoadUserInfomation() {
//
//        //根据登录用户ID更新本地数据库，该ID部门下的所有人员信息
//        RequestParams mRequestParams = new RequestParams();
//        mRequestParams.add("ljyyxDwxxId", MyApplication.getmLoginUser().getUserUnitId());
//        NetWorkApi.getAllUserInfoByCompanyId(UserCenterActivity.this, mRequestParams, new ObjectHttpResponseHandler(UserCenterActivity.this, UserBean.class) {
//            @Override
//            public void Success(int i, Header[] headers, Object object) {
//                try {
//                    UserBean mUserBean = (UserBean) object;
//                    List<User> list = new ArrayList<User>();
//                    MyApplication.getDaoSession().getUserDao().deleteAll();
//                    for (UserBean.RowsBean mRowsBean : mUserBean.getRows()) {
//                        User mUser = new User();
//                        mUser.setLjyyxLoginName(mRowsBean.getLjyyxLoginName());
//                        mUser.setLjyyxWorkerName(mRowsBean.getLjyyxWorkerName());
//                        mUser.setLjyyxWorkerTel(mRowsBean.getLjyyxWorkerTel());
//                        mUser.setDownUnitName(mRowsBean.getDownUnitName());
//                        mUser.setLjyyxDwxxId(mRowsBean.getLjyyxDwxxId());
//                        list.add(mUser);
//                    }
//
//                    MyApplication.getDaoSession().getUserDao().insertOrReplaceInTx(list);
//                } catch (Exception e){
//                    MyToast.showServerError(UserCenterActivity.this);
//                }
//
//
//            }
//
//            @Override
//            public void Failure(int i, Header[] headers, String s, Throwable throwable) {
//            }
//        });
//    }
//
//
//    //更新安全风险字典表
//    private void DownLoadSecurityRisk() {
//
//        NetWorkApi.getAllSecurityRisk(UserCenterActivity.this, new ObjectHttpResponseHandler(UserCenterActivity.this, SecurityRiskBean.class) {
//            @Override
//            public void Success(int i, Header[] headers, Object object) {
//                try {
//                    SecurityRiskBean mSecurityRiskBean = (SecurityRiskBean) object;
//                    List<SecurityRisk> mList = new ArrayList<SecurityRisk>();
//                    MyApplication.getDaoSession().getSecurityRiskDao().deleteAll();
//                    for (SecurityRiskBean.RowsBean mRowsBean : mSecurityRiskBean.getRows()) {
//                        SecurityRisk mSecurityRisk = new SecurityRisk();
//                        mSecurityRisk.setAqfxId(mRowsBean.getAqfxId());
//                        mSecurityRisk.setAqfxDm(mRowsBean.getAqfxDm());
//                        mSecurityRisk.setAqfxNr(mRowsBean.getAqfxNr());
//                        mSecurityRisk.setAqfxNr(mRowsBean.getAqfxNr());
//                        mSecurityRisk.setSgxmId(mRowsBean.getSgxmId());
//                        mList.add(mSecurityRisk);
//                    }
//
//                    MyApplication.getDaoSession().getSecurityRiskDao().insertOrReplaceInTx(mList);
//                } catch (Exception e){
//                    MyToast.showServerError(UserCenterActivity.this);
//                }
//
//            }
//        });
//
//
//    }
//
//    //更新安全风险措施
//    private void DownLoadSecurityProtect() {
//
//        NetWorkApi.getAllProtectMeasures(UserCenterActivity.this, new ObjectHttpResponseHandler(UserCenterActivity.this, ProtectMeasuresBean.class) {
//            @Override
//            public void Success(int i, Header[] headers, Object object) {
//                try {
//                    ProtectMeasuresBean mProtectMeasuresBean = (ProtectMeasuresBean) object;
//                    List<ProtectMeasures> mList = new ArrayList<ProtectMeasures>();
//                    MyApplication.getDaoSession().getProtectMeasuresDao().deleteAll();
//                    for (ProtectMeasuresBean.RowsBean mRowsBean : mProtectMeasuresBean.getRows()) {
//                        ProtectMeasures mProtectMeasures = new ProtectMeasures();
//                        mProtectMeasures.setAqfhcsId(mRowsBean.getAqfhcsId());
//                        mProtectMeasures.setAqfhcsDm(mRowsBean.getAqfhcsDm());
//                        mProtectMeasures.setAqfhcsNr(mRowsBean.getAqfhcsNr());
//                        mProtectMeasures.setAqfhcsNr(mRowsBean.getAqfhcsNr());
//                        mProtectMeasures.setSgxmId(mRowsBean.getSgxmId());
//                        mList.add(mProtectMeasures);
//                    }
//
//                    MyApplication.getDaoSession().getProtectMeasuresDao().insertOrReplaceInTx(mList);
//                } catch (Exception e){
//                    MyToast.showServerError(UserCenterActivity.this);
//                }
//
//            }
//        });
//
//
//    }
//
//    //更新所有单位信息
//    private void DownLoadUnite() {
//
//        NetWorkApi.getAllUniteInfomation(UserCenterActivity.this, new ObjectHttpResponseHandler(UserCenterActivity.this, UniteInfomationBean.class) {
//            @Override
//            public void Success(int i, Header[] headers, Object object) {
//                try {
//                    UniteInfomationBean mBean = (UniteInfomationBean) object;
//                    if (mBean.getMsg() == null) {
//                        MyToast.showToast("加载数据失败");
//
//                    } else {
//                        List<UnitInformation> mList = new ArrayList<UnitInformation>();
//                        for (UniteInfomationBean.RowsBean mRows : mBean.getRows()) {
//                            UnitInformation mInfo = new UnitInformation();
//                            mInfo.setLjyyxDwxxId(mRows.getLjyyxDwxxId());
//                            mInfo.setLjyyxDwxxName(mRows.getLjyyxDwxxName());
//                            mInfo.setLjyyxDwxxType(mRows.getLjyyxDwxxType());
//                            mInfo.setLjyyxDwxxType(mRows.getLjyyxDwxxType());
//                            mInfo.setParentId(mRows.getParentId());
//                            mInfo.setLjyyxDwxxKsdate(mRows.getLjyyxDwxxKsdate());
//                            mInfo.setDeleteFlag(mRows.getDeleteFlag());
//                            mInfo.setCjrId(mRows.getCjrId());
//                            mInfo.setCjrq(mRows.getCjrq());
//                            mInfo.setXgrId(mRows.getXgrId());
//                            mInfo.setXgrq(mRows.getXgrq());
//                            mList.add(mInfo);
//                        }
//                        MyApplication.getDaoSession().getUnitInformationDao().insertOrReplaceInTx(mList);
//                    }
//                } catch (Exception e){
//                    MyToast.showServerError(UserCenterActivity.this);
//                }
//
//            }
//        });
//
//    }

}
